Add qartod and config - #48
Conversation
|
I added qartod.py inside the esdglider folder, and I added qartod-config.yml in esdglider/data. Also, I messed up my branch name because I've been working with Quarto a lot, so the branch should've been qartod-module, but instead I accidentally named it quarto-module. |
There was a problem hiding this comment.
Please remove this file from the pr
| # to prevent file-locking issues during | ||
| # subsequent processing and output writing. | ||
|
|
||
| ds = xr.open_dataset(input_file) |
There was a problem hiding this comment.
I use xr.load_dataset(input_file) rather than these three lines
There was a problem hiding this comment.
Ya that's a better approach, I'll update it.
|
Hi Madi - thanks for this! I've put some comments inline. A couple general ones, happy to discuss any of these: For log messages, please use the syntax For me, having extra blank lines, eg between function calls makes the code less easily readable (example below). For esdglider, I'd like to stick to the principles of a) generally keeping code on one line is the line length is <80, and b) not having extra blank lines between lines in the same function. |
|
Hi Sam, I'll make sure to fix all of these! |
Do you want me to remove the comments in the code (example below)? EVALUATE ALL DATA VARIABLES |
|
No, I think the comments are overall good, although I typically don't like them over logs because (unless it's really complicated) I think the log should be self-explanatory. I would format that block something like: Thanks! |
|
I updated everything based on your comments. If there's anything else, please let me know! |
|
Thank you! This is looking good. I'll try out the fork tomorrow. One other ask - could you add a notebook (to the 'notebooks' folder) that shows a representative example or two of using this functionality? |
|
Yes! Sorry to get back late, I have been traveling. I'll make sure to add a notebook today. |
|
Thanks, this is looking good. The outputs make sense A couple more requests to complete the pr are below; sorry I didn't think to include these initially.
|
d25d5f4 to
a6a226b
Compare
|
I updated the requests you gave, but for visualizing/logging of the qc flags, what would be most helpful for you? Are you interested in seeing exactly when the bad flags occur or just generally how many flags (of each kind) there are? |
|
Thanks @madrichardson! Updates look great. For visualizing/summarizing, I'm thinking both a histogram (or logged summary counts) of the number of each flag per variable, and then a timeseries of the flags. For the timeseries, either using color-coding to mark 'bad' flags, or have the plot only be of the 'bad' flags. |
|
Hi Sam, the Glider DAC folks provided guidance for determining the thresholds for two of the tests for qc'ing. They already have functions for both: get_spike_thresholds() & get_rate_of_change_threshold(). Did you want me to incorporate these in the qartod module? I was thinking I would update qartod.py with these and then edit parts of the script so that if would load the qartod-config.yml, create the config-dictionary, compute the threshold statistics, replace the placeholder thresholds, and then update the config-dictionary so that the qartod-config.yml is never overwritten, just used as a template. Also, I saw you were out of office until August, so no worries about getting back to me until then! |
|
Thanks Madi. This all makes sense to me. I like just updating the config dictionary, rather than having to update qartod-config.yml all the time. When adding functions, please just make sure to provide credit/links in the function docstring that points back to the DAC's original function Also, maybe this happens by default, but will the output nc file have these function-calculated values as an attribute for the applicable quartod variable? Eg, will qartod_density_spike_flag have an attribute that contains the calculated spike thresholds? I think that could be useful for any future troubleshooting |
|
Hi Sam, Sorry for going MIA, I've been busy with some other projects. The output nc file wouldn't have the function calculated values as an attribute for the applicable quartod variable, but I agree that it would be useful to include. I'm thinking that we could store the threshold calculations in a dictionary and then add it as an argument for the create_qc_variables() function. I'm going to try to get the functions implemented by the end of the week, and I'll be working on the qc flag figures as well. |
…lider-madi into pr/madrichardson/48
|
First off, sorry for the commit - I thought I was just pulling changes, but I think a couple of VS Code extensions crossed paths, and so thought they had to merge the PR with the branch for some reason. I don't think my 'commit' actually changes anything (unless it pulled updates from main), but if it did let me know and I'll happily revert. |
|
No worries @madrichardson - this sound good. I'll be around the next couple of weeks, so should be able to respond to things quickly. From some quick browsing, I like how this dataset uses a |
|
I added the threshold functions and now I've created a flag_configuration attribute for each variable that looks like this: What do you think? |
Oops - I meant to link this dataset
That looks awesome! Thanks for wrangling all of that together into that attribute |
@madrichardson these look great - I also like seeing them like that. Thinking out loud, I think a plot like this would be useful for the whole deployment. For deployments with 100s of profiles, it would be hard to scan through 100s of plots - perhaps a CSV file with one column for each flag value, and one row for each profile? I think the (only?) other plot we'll need is one for each variable of the 'timeseries' of the QC flags, like the plots in the 'timeSeries-sci' plot folder. |
|
So are you saying one plot for the entire deployment where for every QC NetCDF in the deployment, accumulate the flag counts for each variable? And then have the CSV file with one column for each flag value, and one row for each profile? |
|
Yep. But happy if you have other suggestions! I think regardless though, the plots function is still going to be the same: a function that takes in an xarray dataset, and does a bar plot of all the _qc variables in that dataset? And then we can either pass that function each profile, or a full deployment. |
|
I think that's a good idea! Where do you want me to put the plotting function? In plots.py, in qartod.py, or another location? |
|
In plots.py would be great |
|
Sorry I keep pestering you with questions, but do you want me to call the plotting function in qartod.py or is that something you'll call somewhere else in the entire processing pipeline? |
|
Not worries at all. I'm doing other glider coding things, so this is a perfect time. For this PR, let's just add the plotting functions, and an example of using them to the notebook. I may want them in plots.esd_all_plots in the future, but let's hold for now until we can see how they feel when we add all the QC pieces to the standard processing scripts. |
|
Sounds good to me, thanks! |
|
Here is the full deployment stacked bar chart plot, the csv file with the flag quantities, and a couple examples of the timeseries plots. Let me know what you think, and if you like them I can push my updates to the PR. |
|
These look great Madi! Thank you! My only request is to add the actual profile index (in addition to the profile name) to the CSV. It's curious that depth has so many suspect flags. I wonder why that is, and if it will be similar for other deployments.
We got a notice from the manufacturer that the cdom data for this deployment is irretrievable. So, it's good that the CDOM data looks so bad! |










No description provided.